/**
 * import store from '@/vuex/store'
 * import {mapState} from 'vuex'
 *  必须
 *
 */
import Vue from 'vue'
import Vuex from 'vuex'
// import * as types from"./ylstore"
import * as types from './types'
Vue.use(Vuex)

const state = {
  imei:null,  //设备唯一标识
  ip:'http://192.168.3.102:16000/elderly',//服務器ip地址
  // ip:'http://221.236.172.57:16000/elderly',//服務器ip地址
  locations:null, //用户位置坐标
  watchPosition:null,//实时监听位置
  isLoading: false, //管理用户loading
  direct:false,//首页路由重定向
  releaseHeight:'0',//用来变化发布高度
  token:'',//token
  videoSrc:null,  //需要发布的视频路径
  homeIndex:null, //首页导航索引
  phone:[],    //动态发布存放图片
  phonenumber:'',//电话号码
  password:'',//密码
  dynamicUrl:null,//判断阅读版块栏目分类
  videoContent:null,//视频动态内容
  userDetail:'',//用户信息
  searchPhone:'',//查询电话号码
  selfdata:'',//当前用户个人信息
  loginStatus:1,//判断登录状态
  playStatus:false,//临时保存消息文件
  msgText:null,//临时保存消息文字
  base64:null,//临时保存图片base64
  videoBlob:null,//临时保存视频缩略图BLOB
  myzip:null,//临时保存压缩图片
  socketStatus:null,//保存socket状态
  sendstatus:1,//保存socket发送状态
  auobj:null,//保存语音播放对象
  invitaObj:null,//保存新建分组邀请好友相关数据
  choseGroup:null,//保存当前操作group
  mapdata:null,//地图数据
  addorfo:null,//判断添加好友还是关注
  userState:null,//用户权限
  stateWrite:null,//权限写入判断
  pedometer:0,//计步器步数
  issueCover:null,//投送卡封面图
  issueContent:null,//
}
/**
 */
const mutations = {
  issueCover(state,n){  //操作投送卡封面图
    state.issueCover = n
  },
  issueContent(state,n){  //操作投送卡
    state.issueContent = n
  },
  videoContent(state,n){
    state.videoContent = n
  },
  videoBlob(state,n){
    state.videoBlob = n
  },
  homeIndex(state,n){
    state.homeIndex = n
  },
  device(state,n){//操作imei
    state.imei = n
  },
  phone(state,msg){
    state.phone = msg
  },
  dynamicUrl(state,msg){
    state.dynamicUrl = msg
  },
  updateLoadingStatus(state, isLoading) { //isloading
    state.isLoading = isLoading;
  },
  videoSrc(state,n){  //操作视频路径
    state.videoSrc = n
  },
  direct(state,data){//首页路由重定向
    state.direct=data
  },
  release(state,n){
    state.releaseHeight = n
  },
  locations(state,n){
    state.locations = n
  },
  phonenumber(state,msg){
    state.phonenumber=msg
  },
  password(state,msg){
    state.password=msg
  },
  userDetail(state,data){//用户个人信息
    state.userDetail=data
  },
  searchPhone(state,phone){//查询用户电话
    state.searchPhone=phone
  },
  selfdata(state,data){//当前用户个人信息
    state.selfdata=data
  },
  loginStatus(state,status){//保存登录状态
    state.loginStatus=status
  },
  playStatus(state,msg){//临时保存消息路径
    state.playStatus=msg
  },
  msgText(state,msg){//临时保存消息路径
    state.msgText=msg
  },
  base64(state,base){//临时保存base64
    state.base64=base
  },
  myzip(state,zip){//压缩
    state.myzip=zip
  },
  socketStatus(state,n){//socket状态
    state.socketStatus=n
  },
  sendstatus(state,n){//scoket发送状态
    state.sendstatus=n
  },
  auobj(state,n){//保存语音播放对象
    state.auobj=n
  },
  invitaObj(state,msg){//保存邀请好友信息
    state.invitaObj=msg
  },
  choseGroup(state,id){//保存当前操作分组id
    state.choseGroup=id
  },
  mapdata(state,data){//保存地图数据
    state.mapdata=data
  },
  addorfo(state,data){//添加或者关注
    state.addorfo=data
  },
  userState(state,data){//用户权限
    state.userState=data
  },
  stateWrite(state,way){//权限写入方式判断
    state.stateWrite=way
  },
  pedometer(state,n){  //计步器步数
    state.pedometer = n
  },
  watchPosition(state,msg){
    state.watchPosition = msg
  },
  [types.LOGIN]: (state, data) => {
    localStorage.token = data;
    state.token = data;
  },
  [types.LOGOUT]: (state) => {
    localStorage.removeItem('token');
    state.token = null
  },
  [types.TITLE]: (state, data) => {
      state.title = data;
  }
}
/**
 * mutations 操作vuex变量方法
 */

export default new Vuex.Store({
	state,
	mutations
})
